<?php
require_once dirname(__FILE__) . '/Item/Interface.php';

class Cms_Resource_Administrator_Item extends BIS_Model_Resource_Db_Table_Row_Abstract implements Cms_Resource_Administrator_Item_Interface
{
    /**
     * Is Administrator profile enabled?
     *
     * @return boolean
     */
    public function isEnabled()
    {
        return (0 == $this->getRow()->status) ? false : true;
    }

    /**
     * Get Administrator full name
     *
     * @return string
     */
    public function getFullname()
    {
        return ucwords($this->getRow()->otherNames) . ' ' . ucwords($this->getRow()->surname);
    }

    /*
     * Get Administrator's Group Permission
     *
     * @return array
     */
     public function getPermission()
    {
        $accessPermission = $this->findParentRow('Cms_Resource_AdministratorGroup', 'Group')->accessPermission;
        $modifyPermission = $this->findParentRow('Cms_Resource_AdministratorGroup', 'Group')->modifyPermission;

        $permission = array();
        $permission['access'] = $accessPermission;
        $permission['modify'] = $modifyPermission;

        return $permission;
    }

    /**
     * Get Administrator Group Id as a role
     *
     * @return int Admin Group Id
     */
    public function getRole()
    {
        return $this->getRow()->adminGroupId;
    }

}